package com.common.util;

import com.common.enums.sys.OsTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author: stefanie-zy
 * @time: 2024/1/29-13:50
 * @description: 服务器工具类
 */
@Slf4j
@Component
@Schema(name = "工具-服务器")
public class OsUtil {

    /**
     * 获取服务器类型
     */
    public static OsTypeEnum getOs() {
        String osName = System.getProperty("os.name").toLowerCase();
        if (osName.contains("win")) {
            return OsTypeEnum.WINDOWS;
        } else if (osName.contains("nix") || osName.contains("nux")) {
            return OsTypeEnum.LINUX;
        } else if (osName.contains("mac")) {
            return OsTypeEnum.MAC;
        } else {
            return OsTypeEnum.OTHER;
        }
    }
}
